import { mapGetters } from "vuex";
import  {api_system} from "src/api/index.js"
import mixins from "src/mixins/setter/pages/matchStatus.js"
export default {
    mixins: [mixins],
    data() {
        return {
            match_status_constant: []
        }
    },
    computed: {
        ...mapGetters({
            selectedSportTypeInfo: 'get_selectedSportTypeInfo',
            allMatchStaus: 'get_allMatchStaus',
            sportId: 'get_sportId'
        }),
    },
    mounted() {
    },
    watch: {
        selectedSportTypeInfo() {
            this.init_matchStatus_when_SportType_changed()
        },
    },
    methods: {
        init_matchStatus_when_SportType_changed() {
            console.log('this.selectedSportTypeInfo');
            console.log(this.selectedSportTypeInfo);
            if (this.selectedSportTypeInfo.id) {
                let params = {
                    keyWord: this.selectedSportTypeInfo.id
                }
                api_system.post_systemtypedict(params).then(res => {
                    let code = this.$lodash.get(res, "data.code")
                    if (code == 200) {
                        let data_matchStatus = this.$lodash.get(res, 'data.data.matchStatus')   
                        data_matchStatus.unshift({
                            value:'',
                            description:'全部'
                        })
                        this.set_sportId(params.keyWord)
                        let data_tournamentLevel = this.$lodash.get(res, 'data.data.tournamentLevel')
                        this.set_allMatchStaus({sportId: this.selectedSportTypeInfo.id, key: 'match_status_constant', arr: data})
                        this.set_allMatchStaus({sportId: this.selectedSportTypeInfo.id, key: 'match_level_constant', arr: data_tournamentLevel})
                    }
                    this.alert_message(res)

                })

            }


        }
    },



}